//
//  LWXCollectionViewCell.m
//  EPA
//
//  Created by lanou3g on 16/4/19.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "LWXCollectionViewCell.h"

@interface LWXCollectionViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@end

@implementation LWXCollectionViewCell

- (void)setModel:(LWXHomeModel *)model {
    if (_model != model) {
        _model = model;
        
    }
}

- (void)layoutSubviews {
    
    self.titleLabel.text = self.model.name;
    
   // [self.imageView sd_setImageWithURL:[NSURL URLWithString:self.model.coverimg]];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.model.coverimg]];
    NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        if (data) {
            dispatch_async(dispatch_get_main_queue(), ^{
                self.imageView.image = [UIImage imageWithData:data];
            });
        }
    }];
    [dataTask resume];
    
}

- (void)awakeFromNib {
    // Initialization code
}

@end
